package com.example.admin.client;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * Created by on 2017/10/23.
 *
 * @author dj
 */
@Component
public class RestClient {
	@Autowired
	private RestTemplate restTemplate;

	@HystrixCommand(fallbackMethod = "testRibbonFallback")
	public String testRibbon() {
		return restTemplate.getForObject("http://test-service/test", String.class);
	}

	public String testRibbonFallback() {
		return "hystrix fallback";
	}
}
